<div id="{$_rs.identifier}_html"></div>
<select name="{$_rs.identifier}_p" id="{$_rs.identifier}_p" lay-ignore onchange="read_city_{$_rs.identifier}()">
	<option value="" province_id=''>请选择…</option>
	<!-- loop from=$_province key=$key value=$value id=$tmpid -->
	<option value="{$value.val}"{if $_rs.content.p == $value.val} selected{/if} province_id="{$value.attr.id}">{$value.val}</option>
	<!-- /loop -->
</select>
<select name="{$_rs.identifier}_c" id="{$_rs.identifier}_c" lay-ignore onchange="read_county_{$_rs.identifier}()" style="display:none" data="{$_rs.content.c}">
	<option value="" city_id=''>请选择…</option>
</select>
<select name="{$_rs.identifier}_a" id="{$_rs.identifier}_a" lay-ignore style="display:none" data="{$_rs.content.a}">
	<option value="" area_id=''>请选择…</option>
</select>
<script type="text/javascript">
var form_pca_{$_rs.identifier}_p = '{$rs.content ? $rs.content.p : ""}';
var form_pca_{$_rs.identifier}_c = '{$rs.content ? $rs.content.c : ""}';
var form_pca_{$_rs.identifier}_a = '{$rs.content ? $rs.content.a : ""}';
function read_city_{$_rs.identifier}()
{
	var province_id = $("#{$_rs.identifier}_p").find("option:selected").attr('province_id');
	if(!province_id){
		$("#{$_rs.identifier}_c").hide();
		$("#{$_rs.identifier}_a").hide();
		return true;
	}else{
		//读城市Ajax
		var url = get_url('inp','xml','file=cities');
		var city = $("#{$_rs.identifier}_c").attr('data');
		$.phpok.json(url,function(data){
			if(data.status != 'ok'){
				alert('内容获取异常：'+data.content);
				return false;
			}
			var info = data.content.city;
			var html = '';
			for(var i in info){
				if(info[i].attr.pid == province_id){
					html += '<option value="'+info[i].val+'" city_id="'+info[i].attr.id+'"';
					if((city && info[i].val == city) || (form_pca_{$_rs.identifier}_c && form_pca_{$_rs.identifier}_c == info[i].val)){
						html += ' selected';
					}
					html += '>'+info[i].val+'</option>';
				}
			}
			$("#{$_rs.identifier}_c").html(html).show();
			$("#{$_rs.identifier}_a").hide();
			read_county_{$_rs.identifier}();
		});
	}
}
function read_county_{$_rs.identifier}()
{
	var city_id = $("#{$_rs.identifier}_c").find("option:selected").attr('city_id');
	if(!city_id){
		$("#{$_rs.identifier}_a").hide();
		return true;
	}else{
		var url = get_url('inp','xml','file=districts');
		var area = $("#{$_rs.identifier}_a").attr('data');
		$.phpok.json(url,function(data){
			if(data.status != 'ok'){
				alert('内容获取异常：'+data.content);
				return false;
			}
			var info = data.content.district;
			var html = '';
			for(var i in info){
				if(info[i].attr.cid == city_id){
					html += '<option value="'+info[i].val+'"';
					if((area && info[i].val == area) || (form_pca_{$_rs.identifier}_a && form_pca_{$_rs.identifier}_a == info[i].val)){
						html += ' selected';
					}
					html += '>'+info[i].val+'</option>';
				}
			}
			if(html){
				$("#{$_rs.identifier}_a").html(html).show();
			}else{
				$("#{$_rs.identifier}_a").hide();
			}
			
		});
	}
}
$(document).ready(function(){
	read_city_{$_rs.identifier}();
});
</script>